﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MMITDomain.Abstract;
using MMITDomain.Entities;

namespace MMITDomain.Concrete
{
    public class EFCurrencyRepository : ICurrencyRepository
    {
        private EFDbContext dbContext = new EFDbContext();
        
        #region ICurrencyRepository Members

        public IQueryable<Entities.Currency> Currencies
        {
            get
            {
                return dbContext.Currencies;
            }

        }

        public void SaveCurrency(Currency objCurrency)
        {
            if (objCurrency.Id == 0)
            {
                dbContext.Currencies.Add(objCurrency);
            }

            dbContext.SaveChanges();
        }

        public void DeleteCurrency(Currency objCurrency)
        {
            dbContext.Currencies.Remove(objCurrency);
            dbContext.SaveChanges();
        }

        public Currency GetCurrencyById(int iCurrencyId)
        {
            return dbContext.Currencies.Find(iCurrencyId);
        }

        #endregion
    }
}
